from manager import sprite_mgr
from settings import *
from constants import STATIC_PATH


class BaseLevel(object):
    __instance = None
    __init_flag = True

    def __new__(cls, *args, **kwargs):
        if not cls.__instance:
            cls.__instance = super().__new__(cls)
        return cls.__instance

    def __init__(self, img="background.png"):
        if self.__init_flag:
            self.__init_flag = False
            # get the display surface
            self.bg_img = os.path.join(STATIC_PATH, img)
            self.display_surface = PG.display.get_surface()
            # get groups
            self.update_groups = sprite_mgr.get_group(PGGroup.update.value)
            self.display_groups = sprite_mgr.get_group(PGGroup.display.value)
            self.collision_groups = sprite_mgr.get_group(PGGroup.collision.value)
            self.enemy_groups = sprite_mgr.get_group(PGGroup.enemy.value)
            self.damage_groups = sprite_mgr.get_group(PGGroup.damage.value)
            self.player_groups = sprite_mgr.get_group(PGGroup.player.value)
            self.player_attack_groups = sprite_mgr.get_group(PGGroup.player_attack.value)
            self.enemy_attack_groups = sprite_mgr.get_group(PGGroup.enemy_attack.value)
            # get statics
            self.arms = sprite_mgr.get_static(PGStaticPos.arm.name)
            self.skills = sprite_mgr.get_static(PGStaticPos.skill.name)
            self.player = sprite_mgr.get_player("player")
